﻿<?php

require("class.phpmailer.php");

$address    =	$_GET["email"];
$content    =	$_GET["content"];
$content    = 	stripslashes($content);

if($address=='' || $content=='')
{
echo "没填Email?";
exit;
}	

if(!preg_match("/(\w+)@\w+\.[a-z]+/", $address, $username))
{
	echo "没填Email?";
	exit;
}
else
{
	$user = $username[1];
}

//echo $address.$content;exit;

// 参数说明(发送到, 邮件主题, 邮件内容, 附加信息, 用户名)
if(smtp_mail($address, "来看看！", $content, $user))
	echo "successful!";
		


function smtp_mail ($sendto_email, $subject, $body, $user_name) {
	 
	 $mail = new PHPMailer(); 
	 $mail->IsSMTP();                // send via SMTP 
	 $mail->Host = "smtp.sohu.com"; // SMTP servers 
	 $mail->SMTPAuth = true;         // turn on SMTP authentication 
	 $mail->Username = "petlovest@sohu.com";   // SMTP username  注意：普通邮件认证不需要加 @域名
	 $mail->Password = "qwe123";        // SMTP password 
	
	 $mail->From = "petlovest@sohu.com";      // 发件人邮箱
	 $mail->FromName =  "wangnan"; 			 // 发件人
	 
	 $mail->CharSet = "GB2312";            		// 这里指定字符集！
	 $mail->Encoding = "base64"; 
	
	 $mail->AddAddress($sendto_email, $user_name);  // 收件人邮箱和姓名
	 $mail->AddReplyTo("yourmail@cgsir.com","cgsir.com"); 
	
	 $mail->WordWrap = 50; 				// set word wrap 
	 $mail->AddAttachment($upload_file); 		// 附件
	 						//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); 
	 $mail->IsHTML(false);  				// send as HTML 
	       						 // 邮件主题
	 $mail->Subject = $subject;	 						// 邮件内容 
	 $mail->Body    = $body;                                                        	
	 $mail->AltBody = $format; 
	 
		if(!$mail->Send()) 
		{ 
			//echo "<script language=javascript>alert('邮件发送有误'); history.go(-1);</script>";			
			echo "邮件发送有误 <p>"; 
			echo "邮件错误信息: " . $mail->ErrorInfo; 
			exit; 
		} 
		else 
		{
			echo "发出去啦!";
		}
}
		

?>